package com.unswift.window.factory;

import java.awt.Color;
import java.awt.LayoutManager;

import javax.swing.BoxLayout;
import javax.swing.JPanel;
import javax.swing.border.Border;

import com.unswift.utils.ObjectUtils;
import com.unswift.window.extend.Form;
import com.unswift.window.extend.TabPanel;

public final class PanelFactory {
	
	public static JPanel create(Color bgColor, Border border, LayoutManager layout){
		JPanel panel=new JPanel(layout);
		if(ObjectUtils.isNotEmpty(bgColor)){
			panel.setBackground(bgColor);
		}
		if(ObjectUtils.isNotEmpty(border)){
			panel.setBorder(border);
		}
		return panel;
	}
	
	public static Form createForm(Color bgColor, Border border, LayoutManager layout){
		Form form=new Form();
		form.setLayout(layout);
		if(ObjectUtils.isNotEmpty(bgColor)){
			form.setBackground(bgColor);
		}
		if(ObjectUtils.isNotEmpty(border)){
			form.setBorder(border);
		}
		return form;
	}
	
	public static JPanel createBox(Color bgColor, Border border, int axis){
		JPanel panel=new JPanel();
		panel.setLayout(new BoxLayout(panel, axis));
		if(ObjectUtils.isNotEmpty(bgColor)){
			panel.setBackground(bgColor);
		}
		if(ObjectUtils.isNotEmpty(border)){
			panel.setBorder(border);
		}
		return panel;
	}
	
	public static TabPanel createTab(Color bgColor, Border border, LayoutManager layout, String type, Object...mainComps){
		TabPanel panel=new TabPanel(type, mainComps);
		panel.setLayout(layout);
		if(ObjectUtils.isNotEmpty(bgColor)){
			panel.setBackground(bgColor);
		}
		if(ObjectUtils.isNotEmpty(border)){
			panel.setBorder(border);
		}
		return panel;
	}
}
